<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/5/21
  Time: 20:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

    <title>个人资料</title>

    <link href="${path}/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
    <link href="${path}/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">
    <!-- layui使用的样式-->
    <link rel="stylesheet" href="${path}/layuiadmin/layui/css/layui.css" media="all">
    <link href="${path}/css/personal.css" rel="stylesheet" type="text/css">
    <link href="${path}/css/infstyle.css" rel="stylesheet" type="text/css">
    <script src="${path}/AmazeUI-2.4.2/assets/js/jquery.min.js" type="text/javascript"></script>
    <script src="${path}/AmazeUI-2.4.2/assets/js/amazeui.js" type="text/javascript"></script>

</head>

<body>
<article>
    <div class="mt-logo">
        <!--头 -->
        <header>
            <jsp:include page="header.jsp"></jsp:include>
        </header>
    </div>
</article>
<div class="nav-table">
    <div class="long-title"><span class="all-goods">全部分类</span></div>
    <jsp:include page="navigation.jsp"></jsp:include>
</div>
<b class="line"></b>
<div class="center">
    <div class="col-main">
        <div class="main-wrap">

            <div class="user-info">
                <!--标题 -->
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">个人资料</strong> /
                        <small>Personal&nbsp;information</small>
                    </div>
                </div>
                <hr/>


                <!--个人信息 -->
                <div class="info-main">
                    <form class="am-form am-form-horizontal">

                        <div class="am-form-group">
                            <label for="username" class="am-form-label">用户名</label>
                            <div class="am-form-content">
                                <input type="text" id="username" value="${user1.username}">

                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="userphone" class="am-form-label">电话</label>
                            <div class="am-form-content">
                                <input id="userphone" type="tel" readonly value="${user1.userphone}">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="userpassword" class="am-form-label">密码</label>
                            <div class="am-form-content">
                                <input type="password" id="userpassword" placeholder="不填写默认不修改密码">

                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-form-label">性别</label>
                            <div class="am-form-content sex" id="usersex">
                                <c:if test="${user1.usersex==null||empty user1.usersex}">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="男" data-am-ucheck> 男
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="女" data-am-ucheck> 女
                                    </label>
                                </c:if>
                                <c:if test="${user1.usersex=='男'}">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="男" data-am-ucheck checked> 男
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="女" data-am-ucheck> 女
                                    </label>
                                </c:if>
                                <c:if test="${user1.usersex=='女'}">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="男" data-am-ucheck> 男
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="usersex" value="女" data-am-ucheck checked> 女
                                    </label>
                                </c:if>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label class="am-form-label">生日</label>
                            <div class="<%--layui-input-inline--%> am-form-content">
                                <div>
                                    <c:if test="${userbirthday==null}">
                                        <input type="text" class="layui-input" id="userbirthday"
                                               placeholder="yyyy-MM-dd">
                                    </c:if>
                                    <c:if test="${userbirthday!=null}">
                                        <input type="text" class="layui-input" id="userbirthday"
                                               placeholder="yyyy-MM-dd"
                                               value="${userbirthday}">
                                    </c:if>
                                </div>
                            </div>
                        </div>

                        <div class="info-btn">
                            <input id="update" type="button" value="保存修改" class="am-btn am-btn-danger">
                        </div>

                    </form>
                </div>

            </div>

        </div>
        <!--底部-->
        <div class="footer">
            <p>
                <em>Copyright © 2006-2019 YONGHUI SUPERSTORES, All Rights Reserved小馋猫超市·版权所有 中国福建省厦门市软园24号
                    客服中心：86-591-83758880 4000601933</em>
            </p>
        </div>
    </div>

    <jsp:include page="aside.jsp"></jsp:include>
</div>

</body>
<!-- layui的js-->
<script src="${path}/layuiadmin/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#userbirthday'
            ,max: 0
        });
    });
</script>
<script type="text/javascript">
    $("#update").click(function () {
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage, layer = layui.layer;
            $.ajax({
                url: "${path}/user.action/updateUserData",
                type: "post",
                dataType: "json",
                data: {
                    "username": $("#username").val(),
                    "userphone": $("#userphone").val(),
                    "userpassword": $("#userpassword").val(),
                    "usersex": $("#usersex input[name='usersex']").val(),
                    "userbirthday": $("#userbirthday").val(),
                    "userid":${user1.userid}
                }, success: function (data) {
                    if (data.msg == "修改成功") {
                        layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                            //修改成功
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 2000}, function () {
                            //修改失败
                            location.reload();
                        });
                    }
                }
            });
        });
    });
</script>
</html>
